#include "SRCommandList.h"
#include <QDebug>

SRCommandList::SRCommandList()
{
	commandList = QList<SRCommand>();
}


SRCommandList::SRCommandList(SRCommand c)
{
	SRCommandList();
	commandList.append(c);
}


SRCommandList::SRCommandList(QList<SRCommand> cl)
{
	SRCommandList();
	commandList.append(cl);
}


SRCommandList::SRCommandList(QString s)
{
	SRCommandList();
	if(!s.isEmpty())
	{
		commandList.append(SRCommand(s));
	}
}


QString SRCommandList::toString()
{
	QString stringRepresentation;

	for(int i=0; i<commandList.size(); i++)
	{
		SRCommand cmd = commandList.at(i);
		stringRepresentation.append(cmd.toString());

		// add command separator character after all commands except the last one
		if(i != commandList.size()-1)
		{
			stringRepresentation.append(SRCommand::commandSeparator);
		}
	}

	return stringRepresentation;
}


QList<SRCommand> SRCommandList::asList()
{
	return commandList;
}


int SRCommandList::size()
{
	return commandList.size();
}


SRCommand SRCommandList::at(int i)
{
	return commandList.at(i);
}


void SRCommandList::append(SRCommand c)
{
	commandList.append(c);
}


void SRCommandList::append(SRCommandList cl)
{
	// iterate over the supplied command list
	for(int i=0; i < cl.size(); i++)
	{
		// append to this SRCommandList object's internal QList
		commandList.append(cl.at(i));

		qDebug() << "APPENDING YEAH YEAH YEAH";
	}
}


bool SRCommandList::isCommandList(QString s)
{
	return s.contains(SRCommand::commandSeparator);
}


void addArgument(QStringList values)
{

}
